<%@page import="java.math.BigDecimal"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Locale"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="net.ge.mosq.utils.Utils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="java.text.DateFormat"%>
<%@page import="net.ge.mosq.web.servlet.form.TransactionForm"%>
<%@page import="net.ge.mosq.web.others.ActionMessage"%>
<%@page import="java.util.Iterator"%>
<%@page import="net.ge.mosq.web.others.ActionMessages"%>
<%@page import="net.ge.mosq.jdo.entity.TransactionInfo"%>
<%@page import="net.ge.mosq.jdo.entity.CodeName"%>
<%@page import="java.util.List"%>
<%@ include file="/taglibs.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function() {
		$("#datepicker").datepicker();
	});
</script>
</head>
<body>
  <%
  	TransactionForm f = (TransactionForm) request.getAttribute(TransactionForm.class.getName());
  	if (request.getAttribute(ActionMessages.GLOBAL_MESSAGE) != null) {
  		ActionMessages ams = (ActionMessages) request.getAttribute(ActionMessages.GLOBAL_MESSAGE);
  		out.println("<ul>");
  		Iterator<ActionMessage> it = ams.get();
  		while (it.hasNext()) {
  			ActionMessage am = it.next();
  			out.println("<li>" + am.getKey() + "</li>");
  		}
  		out.println("</ul>");
  	}
  %>
  <form action="/A001.html" method="post">
    <table class="list-table">
      <tr>
        <td>
          <div id="list-left-header">
            <table width="120px" class="list-contents">
              <colgroup>
                <col width="80px" />
                <col width="40px" />
              </colgroup>
              <tr>
                <th class="title">日期</th>
                <th class="title">序号</th>
              </tr>
            </table>
          </div>
        </td>
        <td>
          <div id="list-right-header">
            <table width="1000px" class="list-contents">
              <colgroup>
                <col width="410px" />
                <col width="400px" />
                <col width="20px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
              </colgroup>
              <tr>
                <th class="title">说明</th>
                <th class="title">资金移动</th>
                <th class="title">清算</th>
                <th class="title"><%=f.getLabel1()%></th>
                <th class="title"><%=f.getLabel2()%></th>
                <th class="title">Balance</th>
              </tr>
            </table>
          </div>
        </td>
      </tr>
      <tr>
        <td>
          <div id="list-left-data">
            <table width="120px" class="list-contents">
              <colgroup>
                <col width="80px" />
                <col width="40px" />
              </colgroup>
              <%
              	List<TransactionInfo> transList = (List<TransactionInfo>) request.getAttribute("transList");
                TransactionInfo transInfo = null;
                for (int i = 0; i < transList.size(); i++) {
                	transInfo = transList.get(i);
              		out.println("<tr class=\""+((i + 1) % 2 == 0 ? "even" : "odd")+"\"><td class=\"date\">" + DateFormatUtils.format(transInfo.getTransDate(), "yyyy/MM/dd", Utils.getUserLocale(request))
              				+ "</td><td class=\"numeric\">" + (transInfo.getNum() == null ? "" : transInfo.getNum().toString()) + "</td></tr>");
              	}
              %>
              <tr>
                <td>
                  <input type="text" name="TransDate" id="datepicker" size="15" style="text-align: center;">
                </td>
                <td style="text-align: right;">
                  <input type="text" name="Num" size="2" style="text-align: right;">
                </td>
              </tr>
            </table>
          </div>
        </td>
        <td>
          <div id="list-right-data">
            <table width="1000px" class="list-contents">
              <colgroup>
                <col width="410px" />
                <col width="400px" />
                <col width="20px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
              </colgroup>
              <%
                NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
              	for (int i = 0; i < transList.size(); i++) {
              %>
              <tr class="<%=(i + 1) % 2 == 0 ? "even" : "odd"%>">
                <td class="text"><%=transList.get(i).getDescription()%></td>
                <td class="numeric"><%=transList.get(i).getTransAccName()%></td>
                <td class="date"><%=transList.get(i).getR()%></td>
                <td class="numeric"><%=transList.get(i).getTransAmountLabel1() == null ? "" : nf.format(transList.get(i).getTransAmountLabel1()) %></td>
                <td class="numeric"><%=transList.get(i).getTransAmountLabel2() == null ? "" : nf.format(transList.get(i).getTransAmountLabel2()) %></td>
                <td class="<%= BigDecimal.ZERO.compareTo(transList.get(i).getBalance()) > 0 ? "numeric-red" : "numeric" %>"><%= nf.format(transList.get(i).getBalance()) %></td>
              </tr>
              <%
              	}
              %>
              <tr>
                <td style="text-align: center;">
                  <input type="text" name="Description" size="100">
                </td>
                <td>
                  <select name="TransAccId" style="text-align: right;">
                    <%
                    	for (CodeName codeName : f.getTransIds()) {
                    		out.println("<option value=\"" + codeName.getCode() + "\">" + codeName.getName() + "</option>");
                    	}
                    %>
                  </select>
                </td>
                <td>
                  <input type="checkbox" name="R">
                </td>
                <td>
                  <input type="text" name="Plus">
                </td>
                <td>
                  <input type="text" name="Minus">
                </td>
                <td>
                  <input type="submit">
                </td>
              </tr>
            </table>
          </div>
        </td>
      </tr>
    </table>
    <input type="hidden" name="ActionFlg" value="1">
    <input type="hidden" name="CurrentAccId" value="<%=f.getCurrentAccId()%>">
  </form>
</body>
</html>